#ifndef FILTER_SHOW_H
#define FILTER_SHOW_H

#include <QWidget>
#include <QTableWidgetItem>
#include "log_save.h"
#include "file_save_get.h"

#define LIST_COLUM 6
#define LIST_ROW  32

#define DATA_PACK_LEN  LIST_ROW

#define PRO_LEN_INDEX 2
#define PRO_NAME_INDEX 1
#define PRO_TYPE_INDEX 3
#define PRO_HEX_VALUE_INDEX 4
#define PRO_VALUE_INDEX 5

#define TYPE_UINT "Uint"
#define TYPE_INT "Int"
#define TYPE_FLOAT "Float"

enum type_
{
    E_TYPE_UINT = 1,
    E_TYPE_INT = 2,
    E_TYPE_FLOAT = 3
};

namespace Ui {
class filter_show;
}

class filter_show : public QWidget
{
    Q_OBJECT

public:
    explicit filter_show(QWidget *parent = nullptr);
    ~filter_show();

private:
    Ui::filter_show *ui;
    void closeEvent(QCloseEvent *event) override;

private:
    QByteArray data_buf; /*传递原始数据的数组*/
    Log_save * log_save = nullptr; /*保存日志的文件*/
    QStringList type_items;
    uint32_t protocol_arry[LIST_ROW] = {0}; /*保存协议字段长度*/
    uint32_t protocol_type_arry[LIST_ROW] = {0}; /*保存协议字段类型*/

    File_save_get * table_json;
private:
    void init_show_info(void);
    void   put_info_to_widget(uint32_t h_row,uint32_t h_colum,QString data,QColor h_color,uint8_t state);
    QString  read_param_from_widget(uint32_t h_row,uint32_t h_colum);
    QWidget * read_widget_from_widget(uint32_t h_row, uint32_t h_colum);
    void show_user_data(void);
    void put_data_to_widget(void);
public:
    void Update_filter_buf(uint8_t * data,uint16_t lenth);
    int get_checkBox_parse_recv_state(void);

signals:
    void close_wid(void);
    void Update_filter_buf_signal(int len);
private slots:
    void Update_filter_process(int len);

    void on_tableWidget_show_info_itemChanged(QTableWidgetItem *item);
    void on_checkBox_perse_protocol_clicked(bool checked);

};

#endif // FILTER_SHOW_H
